package ynu.edu.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Getter;
import lombok.Setter;

import javax.persistence.*;
import java.util.Set;

@Entity
@Getter
@Setter
@DiscriminatorValue("3")
public class Business extends User{
    @Column
    private String name;
    @OneToMany(mappedBy = "business",
            fetch = FetchType.LAZY,
            orphanRemoval = true,
            cascade = CascadeType.ALL)
    @JsonIgnore
//    @JsonIgnoreProperties(value = {"business"})
    private Set<Shop> shops;
    @OneToMany(mappedBy = "business",
            fetch = FetchType.LAZY,
            orphanRemoval = true,
            cascade = CascadeType.ALL)
    @JsonIgnore
//    @JsonIgnoreProperties(value = {"business"})
    private Set<Item> items;
    public void addShop(Shop shop){
        shops.add(shop);
    }
    public void addItem(Item item){
        items.add(item);
    }
}
